package com.chen.rabbitmq.utils;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;


/**
 * @author Y·C
 * @version 1.0.0
 * @ClassName RabbitMqUtils.java
 * @Description 创建rabbitMq连接工厂创建信道的工具类
 * @createTime 2023年05月08日 11:13:00
 */
public class RabbitMqUtils {
    //得到一个连接的channel
    public static Channel getChannel() throws Exception{
        //创建链接工厂
        ConnectionFactory factory = new ConnectionFactory();
        //工厂IP连接RabbitMQ的队列
        factory.setHost("114.55.37.219");
        //用户名
        factory.setUsername("guest");
        //密码
        factory.setPassword("guest");
        //创建链接
        Connection connection = factory.newConnection();
        //获取信道
        Channel channel = connection.createChannel();

        return channel;
    }

}
